import time
import numpy as np
from concurrent.futures import ProcessPoolExecutor
def fib(n):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return fib(n-1) + fib(n-2)


def main():

    fib_range = list(range(1, 35))
    times = []
    for run in range(10):
        start = time.time()
        with ProcessPoolExecutor() as do:
             do.map(fib, fib_range)
        end = time.time()
        times.append(end-start)
    print('波那契数列fib(35)计算平均耗时 {:.3f}。'.format(np.mean(times)))

if __name__ == '__main__':
    main()

